<?php
/**
* @author Tibor Pino (tibor.pino@gmail.com)
* @license released under GNU Public License v. 2
* @copyright Copyright (c) 2007, Tibor Pino
*
*/

class RatingHelper extends AppHelper
{
	function getRating($data) {
		$good = 0;
		$countData = count($data);
		
		if($countData>0) {
			foreach ($data as $rating) {
				if($rating['value']==1) $good++;
			}
			$percent = intval(100/$countData*$good);
			return $this -> output($percent);
		} else {
			return $this->output(0);
		}
	}
	
	function amount($data) {
		return $this->output(count($data));
	}
}
?>